package com.kun.peng;

import com.kun.peng.annotation.rest.AnonymousGetMapping;
import com.kun.peng.utils.SpringContextHolder;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.security.core.context.SecurityContextHolder;


/**
 * @author xuebaopeng
 */
@EnableAsync
@Slf4j
@SpringBootApplication
@MapperScan(value="com.kun.peng.system.mapper,com.kun.peng.generator.mapper,com.kun.peng.logging.mapper")
public class KunPengServerApplication {
    @Bean
    public SpringContextHolder springContextHolder() {
        return new SpringContextHolder();
    }

    @Bean
    public SecurityContextHolder securityContextHolder(){
        SecurityContextHolder securityContextHolder=new SecurityContextHolder();
        SecurityContextHolder.setStrategyName(SecurityContextHolder.MODE_INHERITABLETHREADLOCAL);
        return securityContextHolder;
    }
    public static void main(String[] args) {
        SpringApplication.run(KunPengServerApplication.class, args);
    }
    /**
     * 访问首页提示
     *
     * @return /
     */
    @AnonymousGetMapping("/")
    public String index() {
        return "Backend service started successfully";
    }
}
